/*
 * ******************************************************
 *   Copyright ©, 2017-2020, 安徽财金信息科技有限公司
 * ******************************************************
 */
package com.wy.poties.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wy.poties.dao.PoetDao;
import com.wy.poties.vo.ApiResult;
import com.wy.poties.vo.BannerVO;
import com.wy.poties.vo.Page;
import com.wy.poties.vo.PoetryVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>Title:</p>
 * 一句话功能说明
 * <p>Description:</p>
 * 功能描述
 *
 * @author cj021_汪洋
 * @version 1.0
 * @date 2020-11-15 21:16
 */
@Service
public class PoetService {
    @Resource
    PoetDao poetDao;


    public ApiResult homeBanner() {
        List<BannerVO> data = poetDao.getHomeBanner();
        return ApiResult.success(data);
    }

    public ApiResult homeFantisyPoetry(Integer pageSize, Integer pageNum) {
        if (null == pageSize || pageSize == 0) {
            pageSize = 20;
        }
        if (null == pageNum || pageNum == 0) {
            pageNum = 1;
        }

        // 分页
        PageHelper.startPage(pageNum, pageSize);
        List<PoetryVO> data = poetDao.getHomeFantisyPoetry();
        // 取分页信息
        PageInfo<PoetryVO> pageInfo = new PageInfo<>(data);
        Page<PoetryVO> page = Page.getConvertPage(pageNum, pageSize, pageInfo);
        return ApiResult.success(page);

    }
}